package main

import (
	"fmt"
	cli "github.com/urfave/cli/v2"
	"os"
)

func main() {
	app := cli.NewApp()
	app.Name = "boom"
	app.Usage = "make an explosive entrance"
	app.Version = "2.0"
	app.Action = func(context *cli.Context) error {
		fmt.Println("test cli for example")
		return nil
	}

	app.Flags = []cli.Flag{
		&cli.StringFlag{
			Name:  "lang, l",
			Value: "english",
			Usage: "Language for the greeting",
		},
	}

	app.Commands = []*cli.Command{
		{
			Name:    "complete",
			Aliases: []string{"c"},
			Usage:   "complete a task on the list",
			Action: func(context *cli.Context) error {
				l := context.Args().First()
				fmt.Println("+++",l)
				fmt.Println("serve:", context.String("lang"))
				fmt.Println("===> complate ==>>>")
				return nil
			},
		},
	}

	if err:=app.Run(os.Args);err!=nil{
		panic(err)
	}
}

// go run main.go --lang china complete
